package cn.minsh.lims.eoms.modules.app.controller;

import cn.minsh.lims.eoms.common.utils.PageUtils;
import cn.minsh.lims.eoms.common.utils.ParamUtils;
import cn.minsh.lims.eoms.common.utils.R;
import cn.minsh.lims.eoms.modules.app.controller.req.app.AppUserInspectionListReq;
import cn.minsh.lims.eoms.modules.app.controller.req.app.AppUserInspectionSubmitAndCloseReq;
import cn.minsh.lims.eoms.modules.app.controller.req.app.AppUserInspectionSubmitResultReq;
import cn.minsh.lims.eoms.modules.app.controller.res.InspectionOrderInfoByPlanIdRes;
import cn.minsh.lims.eoms.modules.app.controller.res.UserInspectionPlanInfoRes;
import cn.minsh.lims.eoms.modules.app.controller.res.UserInspectionPlanRes;
import cn.minsh.lims.eoms.modules.app.entity.PlanAgentEntity;
import cn.minsh.lims.eoms.modules.app.entity.UserInspectionPlanEntity;
import cn.minsh.lims.eoms.modules.app.enums.BusiTypeEnum;
import cn.minsh.lims.eoms.modules.app.enums.PlanStatusEnum;
import cn.minsh.lims.eoms.modules.app.service.PlanAgentService;
import cn.minsh.lims.eoms.modules.app.service.UserInspectionPlanService;
import cn.minsh.lims.eoms.modules.app.utils.UserUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;


/**
 * 用户巡检计划
 *
 * @author lht
 * @email sunlightcs@gmail.com
 * @date 2021-04-26 02:30:42
 */
@RestController
@RequestMapping("app/inspectionPlan")
@Api(tags = "手机端-巡检计划(新增,扫描计划获取当天工单)")
public class AppInspectionPlanController extends AbstractController{
    @Autowired
    private UserInspectionPlanService userInspectionPlanService;
    @Autowired
    private PlanAgentService planAgentService ;

    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @ApiOperation("根据巡检计划查询当天的巡检工单详情（扫描巡检计划二维码巡检）")
    @ApiResponses({
            @ApiResponse(code = 200,message = "ok",response = InspectionOrderInfoByPlanIdRes.class)
    })
    public R info(@PathVariable("id") Long id,HttpServletRequest request){
        InspectionOrderInfoByPlanIdRes userInspectionPlan = userInspectionPlanService.queryByPlanId(id);
        userInspectionPlan.setLoginUserId(UserUtils.getUserId(request));
        return R.ok().put("data", userInspectionPlan);
    }

}
